﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CompiladorCentura
{
    public partial class frmCompiladorCentura : Form
    {
        ToolsCentura.ToolsCentura TC;
        bool update;
        bool compile;
        DataSet dsConfig;


        public frmCompiladorCentura()
        {
            InitializeComponent();
        }

        private void frmCompiladorCentura_Load(object sender, EventArgs e)
        {
            TC = new ToolsCentura.ToolsCentura();
            TC.Notificar += new Action<string>(TC_Notificar);
            txtActiveX.Text = TC.ActiveXLibraries;
            txtGlobal.Text = TC.GlobalPath;
            update = true;
            compile = true;
            dsConfig = new DataSet();
        }

        void TC_Notificar(string obj)
        {
            dtgFiles.Refresh();
        }

        private void btnFolderBrowser_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog(this) == DialogResult.OK)
            {
                txtVersao.Text = fbd.SelectedPath;
            }
        }

        private void btnCarregar_Click(object sender, EventArgs e)
        {
            TC.LoadProjectFiles(txtFonte.Text, true, txtVersao.Text);
            dtgFiles.DataSource = TC.ProjectFiles;
        }

        private void btnVersao_Click(object sender, EventArgs e)
        {
            TC.SetAllNewVersion(txtVersao.Text);
        }

        private void btnVersionarTodos_Click(object sender, EventArgs e)
        {
            update = !update;
            TC.SetAllUpdate(update);
        }

        private void btnCompilarTodos_Click(object sender, EventArgs e)
        {
            compile = !compile;
            TC.SetAllCompile(compile);
        }

        private void btnProcessar_Click(object sender, EventArgs e)
        {
            TC.ActiveXLibraries = txtActiveX.Text;
            TC.GlobalPath = txtGlobal.Text;
            TC.BuildFilesCentura();
        }
    }
}
